package com.springboot.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/hello")
public class HelloController {

    @Value("${hello.name}")
    private String name;

    // 只能用string接值
    @Value("${hello.age}")
    private String age;

    // http://localhost:8080/hello/boot即可访问，默认8080端口，默认根路径。后面我在配置文件里改了
    @GetMapping("/boot")
    public String hello() {
        return "Hello Spring Boot3! I am " + name + " and I am " + age + " years old.";
    }
}
